package sk.fei.vrml.objects;

import java.awt.Font;

import com.sun.opengl.util.j2d.TextRenderer;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import cv97.field.SFNode;

/**
 * VrmlText class represents VRML object Text. Properties are array string,
 * fontStyle, array length and maxExtend. Array String contains texts to be displayed.
 * FontStyle is VRML node. Lenght is array of lengths of strings (not number of
 * characters but metric length). Strings then will be expanded or compressed.
 * If lenght is 0, string should neither be expanded nor compressed. MaxLenght
 * limits scaling down.
 * 
 * http://www.lighthouse3d.com/vrml/tutorial/index.shtml?text
 * 
 * Text {
 *		exposedField MFString string []
 *		exposedField SFNode fontStyle NULL
 *		exposedField MFFloat length []
 *		exposedField SFFloat maxExtent 0.0
 *	}
 *
 * FontStyle node
 * 
 * http://www.lighthouse3d.com/vrml/tutorial/index.shtml?fonts
 * 
 * FontStyle {
 *	    family "SERIF"
 *	    horizontal TRUE
 *	    justify "BEGIN"
 *	    language ""
 *	    leftToRight TRUE
 *	    size 1.0
 *	    spacing 1.0
 *	    topToBottom TRUE
 *	}
 * 
 * 
 * @author anubis
 * 
 */
public class VrmlText extends VrmlObject {
	private String[] strings;
	private SFNode fontStyle;
	private int[] lenght;
	private float maxExtent;
	private TextRenderer renderer;

	public VrmlText(String[] strings, SFNode fontStyle, int[] lenght, float maxExtent) {
		this.strings = strings;
		this.fontStyle = fontStyle;
		this.lenght = lenght;
		this.maxExtent = maxExtent;
		renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 72));
	}
	
	public void draw(GLAutoDrawable GLAutoDrawable) {
		//renderer.beginRendering(GLAutoDrawable.getSize().width, GLAutoDrawable.getSize().height);
		renderer.setColor(1.0f, 0.2f, 0.2f, 0.8f);
		for (String str : strings) {
			renderer.draw(str, 0, 0);
		}
		renderer.endRendering();
		
     
	}

	public String toString() {
		return "Text";
	}
}
